package com.homeworkitem.entity;

import java.util.Objects;

/**
 * 描述: 鲜花实体类
 *
 * @author CodeYang
 * @version 2020/12/17 11:23
 */
public class Flower {
    /**
     * 订单编号
     */
    private String num;
    /**
     * 鲜花名称
     */
    private String name;
    /**
     * 销售数量
     */
    private int salesVolume;
    /**
     * 价格
     */
    private double price;
    /**
     * 日期
     */
    private String date;
    /**
     * 销售人员
     */
    private String sellerPerson;
    /**
     * 备注
     */
    private String remarks;

    public Flower() {
    }

    public Flower(String num, String name, int salesVolume, double price, String date, String sellerPerson, String remarks) {
        this.num = num;
        this.name = name;
        this.setSalesVolume(salesVolume);
//        this.salesVolume = salesVolume;
        this.setPrice(price);
//        this.price = price;
        this.date = date;
        this.sellerPerson = sellerPerson;
        this.remarks = remarks;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSalesVolume() {
        return salesVolume;
    }

    public void setSalesVolume(int salesVolume) {
        // 设置销售数量不能为负数 ---设为0
        this.salesVolume = salesVolume < 0 ? 1 : salesVolume;
//        this.salesVolume = salesVolume;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        // 鲜花价格不能为负数 如果为负数 设为0
        this.price = price < 0 ? 0 : price;
//        this.price = price;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getSellerPerson() {
        return sellerPerson;
    }

    public void setSellerPerson(String sellerPerson) {
        this.sellerPerson = sellerPerson;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Override
    public String toString() {
        return "Flower{" +
                "num='" + num + '\'' +
                ", name='" + name + '\'' +
                ", salesVolume=" + salesVolume +
                ", price=" + price +
                ", date='" + date + '\'' +
                ", sellerPerson='" + sellerPerson + '\'' +
                ", remarks='" + remarks + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Flower flower = (Flower) o;
        return salesVolume == flower.salesVolume &&
                Double.compare(flower.price, price) == 0 &&
                num.equals(flower.num) &&
                name.equals(flower.name) &&
                date.equals(flower.date) &&
                sellerPerson.equals(flower.sellerPerson) &&
                remarks.equals(flower.remarks);
    }

    @Override
    public int hashCode() {
        return Objects.hash(num, name, salesVolume, price, date, sellerPerson, remarks);
    }
}
